﻿<c:BaseControl x:Class="personalplaner.plugins.plananalysis.YearOverview"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             xmlns:p="clr-namespace:personalplaner.plugins.plananalysis.Properties"
             xmlns:c="clr-namespace:personalplaner.common.controls;assembly=personalplaner.common"
             xmlns:conv="clr-namespace:personalplaner.common.converters;assembly=personalplaner.common"
             xmlns:vm="clr-namespace:personalplaner.common.mvvm.factory;assembly=personalplaner.common"
             xmlns:fac="clr-namespace:personalplaner.plugins.plananalysis.viewmodels.factories"
               xmlns:k="clr-namespace:personalplaner.common.themes;assembly=personalplaner.common"
               vm:ViewModelLoader.FactoryType="{x:Type fac:YearOverviewModelFactory}">
    
    <Control.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/personalplaner.plugins.plananalysis;component/resources/DataGridStyles.xaml"/>
                <ResourceDictionary>
                    
                    <conv:ColorToSolidColorBrushConverter x:Key="colorToBrush"/>
                    <BooleanToVisibilityConverter x:Key="boolToVis"/>

                    <DataTemplate x:Key="PART_CellTemplate">
                        <Grid>
                            <Border Background="{Binding BackgroundColor, Converter={StaticResource colorToBrush}}" Focusable="False"/>
                            <Border Background="{Binding Color, Converter={StaticResource colorToBrush}}">
                                <TextBlock Text="{Binding Name}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="2,1,2,1" FontWeight="DemiBold" FontSize="10"/>
                            </Border>
                        </Grid>
                    </DataTemplate>
                </ResourceDictionary>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Control.Resources>
    
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="60"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition />
        </Grid.RowDefinitions>
        
        <Grid >
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <TextBlock Text="Jahr" Margin="40,15,20,0" FontWeight="Heavy" Foreground="{DynamicResource {x:Static k:ResourceKeys.ForegroundBrush}}" /><!--Foreground="#E1FFFFFF"-->
            <ComboBox Grid.Column="1" Margin="0,15,0,0" HorizontalAlignment="Left" ItemsSource="{Binding Years}" SelectedItem="{Binding SelectedYear}" Width="150">
                <ComboBox.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding Jahr}" x:Name="txt" Foreground="Black" FontWeight="Medium" Margin="5,0,0,0" />

                        <DataTemplate.Triggers>
                            <DataTrigger Binding="{Binding Status}" Value="Inactive">
                                <Setter TargetName="txt" Property="Foreground" Value="Gray"/>
                            </DataTrigger>
                        </DataTemplate.Triggers>
                    </DataTemplate>
                </ComboBox.ItemTemplate>
            </ComboBox>
        </Grid>

        <Button Grid.Row="0" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,-23,10,10" Command="{Binding PrintCommand}">
            <Button.Template>
                <ControlTemplate TargetType="Button">
                    <Border Background="Transparent" HorizontalAlignment="Center" Cursor="Hand">
                        <ContentPresenter ContentSource="Content" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                    </Border>
                </ControlTemplate>
            </Button.Template>
            <TextBlock Text="{x:Static p:Resources.Print}" FontSize="14" FontWeight="Heavy" Foreground="{DynamicResource {x:Static k:ResourceKeys.ForegroundBrush}}" /><!--Foreground="#E1FFFFFF"-->
        </Button>

        <ScrollViewer Margin="10,0,10,10" Grid.Row="1" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" >
            <Grid x:Name="grids">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>

                <DataGrid Name="HeaderGrid" Visibility="{Binding IsYearPlaned, Converter={StaticResource boolToVis}}"
                      ItemsSource="{Binding Collection}" 
                                      Style="{StaticResource GridStyle}"
                                      ColumnHeaderStyle="{StaticResource DataGridColumnHeaderStyle1}"
                                      VerticalScrollBarVisibility="Disabled"
                                      FontWeight="DemiBold">
                    <DataGrid.GroupStyle>
                        <GroupStyle ContainerStyle="{StaticResource TeamHeaderStyle}">
                            <GroupStyle.Panel>
                                <ItemsPanelTemplate>
                                    <DataGridRowsPresenter/>
                                </ItemsPanelTemplate>
                            </GroupStyle.Panel>
                        </GroupStyle>
                    </DataGrid.GroupStyle>
                    <DataGrid.Columns>
                        <c:DataGridPlanItemTemplateColumn Header="Plan">
                            <c:DataGridPlanItemTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Name}" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5,1,20,1"/>
                                </DataTemplate>
                            </c:DataGridPlanItemTemplateColumn.CellTemplate>
                        </c:DataGridPlanItemTemplateColumn>
                    </DataGrid.Columns>
                </DataGrid>

                <DataGrid x:Name="DiensteGrid"  Grid.Column="1"  Margin="5,0,0,0" Visibility="{Binding IsYearPlaned, Converter={StaticResource boolToVis}}"
                                      Style="{StaticResource GridStyle}"
                                      ColumnHeaderStyle="{StaticResource DataGridColumnHeaderStyle2}">
                    <DataGrid.GroupStyle>
                        <GroupStyle ContainerStyle="{StaticResource TeamHeaderStyle}">
                            <GroupStyle.Panel>
                                <ItemsPanelTemplate>
                                    <DataGridRowsPresenter />
                                </ItemsPanelTemplate>
                            </GroupStyle.Panel>
                        </GroupStyle>
                    </DataGrid.GroupStyle>
                </DataGrid>

                <DataGrid  Grid.Column="2" Margin="5,0,0,0"  Visibility="{Binding IsYearPlaned, Converter={StaticResource boolToVis}}"
                          ItemsSource="{Binding Collection}" 
                          Style="{StaticResource GridStyle}"
                          ColumnHeaderStyle="{StaticResource DataGridColumnHeaderStyle1}"
                          VerticalScrollBarVisibility="Disabled"
                          FontWeight="DemiBold">
                    <DataGrid.GroupStyle>
                        <GroupStyle ContainerStyle="{StaticResource TeamHeaderStyle}">
                            <GroupStyle.Panel>
                                <ItemsPanelTemplate>
                                    <DataGridRowsPresenter/>
                                </ItemsPanelTemplate>
                            </GroupStyle.Panel>
                        </GroupStyle>
                    </DataGrid.GroupStyle>
                    
                    <DataGrid.Columns>
                        
                        <c:DataGridPlanItemTemplateColumn Header="Soll">
                            <c:DataGridPlanItemTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Soll}" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="2,0,2,0" />
                                </DataTemplate>
                            </c:DataGridPlanItemTemplateColumn.CellTemplate>
                        </c:DataGridPlanItemTemplateColumn>
                        <c:DataGridPlanItemTemplateColumn Header="Haben">
                            <c:DataGridPlanItemTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Haben}" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="2,0,2,0" />
                                </DataTemplate>
                            </c:DataGridPlanItemTemplateColumn.CellTemplate>
                        </c:DataGridPlanItemTemplateColumn>
                        <c:DataGridPlanItemTemplateColumn Header="Saldo">
                            <c:DataGridPlanItemTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Saldo}" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="2,0,2,0" />
                                </DataTemplate>
                            </c:DataGridPlanItemTemplateColumn.CellTemplate>
                        </c:DataGridPlanItemTemplateColumn>
                        <c:DataGridPlanItemTemplateColumn Header="Anp.">
                            <c:DataGridPlanItemTemplateColumn.CellTemplate>
                                <DataTemplate>
                                        <TextBlock Text="{Binding Anpassung}" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="2,0,2,0"/>
                                </DataTemplate>
                            </c:DataGridPlanItemTemplateColumn.CellTemplate>
                        </c:DataGridPlanItemTemplateColumn>
                        <c:DataGridPlanItemTemplateColumn Header="Diff">
                            <c:DataGridPlanItemTemplateColumn.CellTemplate>
                                <DataTemplate>
                                        <TextBlock Text="{Binding Differenz}" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="2,0,2,0"/>
                                </DataTemplate>
                            </c:DataGridPlanItemTemplateColumn.CellTemplate>
                        </c:DataGridPlanItemTemplateColumn>
                    </DataGrid.Columns>
                </DataGrid>

            </Grid>

        </ScrollViewer>

    </Grid>
</c:BaseControl>
